#ifndef VENUS_COMMON_GAUSSIAN_H
#define VENUS_COMMON_GAUSSIAN_H

#include <math.h>

namespace venus {
template< typename T >
void Gaussian1D(T weights[], int R, T sigma) {
	T sigma_2 = sigma * sigma;
	const T inv_two_sigma_squared = 0.5f / sigma_2;
	for ( unsigned weight = 0; weight < R; ++weight ) {
		const T x = T( weight * weight );
		weights[ weight ] = exp( - x * inv_two_sigma_squared );
	}

	//normalize
	T sum = 0;
	for ( unsigned int i = 1; i < R; ++i )
		sum +=  weights[ i ] + weights[ i ];
	sum += weights[0];
	for ( unsigned int i = 0; i < R; ++i )
		weights[ i ] /= sum;
}
} // namespace venus

#endif // VENUS_COMMON_GAUSSIAN_H
